var __extends =
    (this && this.__extends) ||
    (function () {
      var e = function (t, i) {
        return (e =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (e, t) {
              e.__proto__ = t;
            }) ||
          function (e, t) {
            for (var i in t)
              Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
          })(t, i);
      };
      return function (t, i) {
        function n() {
          this.constructor = t;
        }
        if ("function" != typeof i && null !== i)
          throw new TypeError(
            "Class extends value " + String(i) + " is not a constructor or null"
          );
        e(t, i),
          (t.prototype =
            null === i
              ? Object.create(i)
              : ((n.prototype = i.prototype), new n()));
      };
    })(),
  JueXingMainController = (function (e) {
    function t() {
      var t = e.call(this) || this;
      return (
        t.btn_juexing_back.on(Laya.Event.CLICK, t, t.onBackPre),
        t.btn_juexing_shuoming.on(Laya.Event.CLICK, t, t.onDidShuoMingAction),
        t.btn_juexing_tisheng.on(Laya.Event.CLICK, t, t.onDidTiShengAction),
        WebSocketService.addListener({
          caller: t,
          code: 6418,
          method: t.onLoadJueXingDataFn,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 6421,
          method: t.onLoadJXDescrDataFn,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 6415,
          method: t.onLoadJXLingWuDataFn,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 6416,
          method: t.onLoadJXXiuLianDataFn,
        }),
        t
      );
    }
    return (
      __extends(t, e),
      (t.showJueXingMainView = function (e) {
        null == this.jueXingVC && (this.jueXingVC = new t()),
          this.jueXingVC.initLabelText(),
          (this.jueXingVC.subDict = e),
          WebSocketService.send({ c: 6421, d: { cid: e.id } });
        var i = e.name.split(")"),
          n = e.name;
        i.length > 1 && (n = i[1]);
        var a = Dictionary.subHeroData[n];
        return (
          a && WebSocketService.send({ c: 6418, d: { id: a.id } }),
          (this.jueXingVC.label_jxHero_name.text = "副将:" + e.name),
          (this.jueXingVC.label_jxHero_id.text = "ID:" + e.id),
          (this.jueXingVC.label_jxhyd_num.text = ""),
          this.jueXingVC
        );
      }),
      (t.prototype.initLabelText = function () {
        (this.label_chengzhang_min.text = ""),
          (this.label_chengzhang_max.text = ""),
          (this.label_qixue_min.text = ""),
          (this.label_qixue_max.text = ""),
          (this.label_jingli_min.text = ""),
          (this.label_jingli_max.text = ""),
          (this.label_gongji_min.text = ""),
          (this.label_gongji_max.text = ""),
          (this.label_sudu_min.text = ""),
          (this.label_sudu_max.text = ""),
          (this.label_juexing_name.text = "-"),
          (this.label_juexing_lvl.text = "-"),
          (this.label_juexing_rate.text = "-"),
          (this.label_juexing_effect.text = "-"),
          (this.label_juexing_descr.text = "-"),
          (this.label_juexing_needPoint.text = "-"),
          (this.image_juexing_img.skin = "");
      }),
      (t.prototype.onLoadJueXingDataFn = function (e) {
        0 == e.code
          ? ((this.label_juexing_name.text = e.data.name),
            (this.label_juexing_descr.text = e.data.descr))
          : ToastView.toastView(e.msg);
      }),
      (t.prototype.onLoadJXDescrDataFn = function (e) {
        if (0 == e.code) {
          (this.btn_juexing_tisheng.label = "提升"),
            (this.label_lingwu_tips.visible = !0);
          var t = e.data;
          (this.label_juexing_name.text = t.talentName),
            (this.label_juexing_lvl.text = t.lvl + "级"),
            (this.label_juexing_rate.text = t.rate + "%"),
            (this.label_juexing_needPoint.text =
              "升级需要 " + t.needExp + " 点"),
            (this.label_juexing_effect.text = t.effect),
            (this.label_jxhyd_num.text = "（魂元丹：" + t.num + "个）"),
            (this.label_chengzhang_min.text = t.czl),
            (this.label_chengzhang_max.text = t.czl2),
            (this.label_qixue_min.text = t.hp),
            (this.label_qixue_max.text = t.hp2),
            (this.label_jingli_min.text = t.mp),
            (this.label_jingli_max.text = t.mp2),
            (this.label_gongji_min.text = t.ap),
            (this.label_gongji_max.text = t.ap2),
            (this.label_sudu_min.text = t.sp),
            (this.label_sudu_max.text = t.sp2);
        } else
          ToastView.toastView(e.msg),
            (this.btn_juexing_tisheng.label = "领悟"),
            (this.label_lingwu_tips.visible = !1);
      }),
      (t.prototype.onDidShuoMingAction = function () {
        var e = CaslnoRulesView.showCaslRuleView("JueXingSM");
        (e.y = 50), (e.height = 570), Laya.stage.addChild(e);
      }),
      (t.prototype.onDidTiShengAction = function (e) {
        console.log(e.target.label),
          "领悟" == e.target.label
            ? NormalDialog.showNormalDialog(
                "领悟觉醒技能将消耗100金币",
                this,
                this.onsureLingWu
              )
            : WebSocketService.send({ c: 6416, d: { cid: this.subDict.id } });
      }),
      (t.prototype.onsureLingWu = function () {
        WebSocketService.send({ c: 6415, d: { cid: this.subDict.id } });
      }),
      (t.prototype.onLoadJXLingWuDataFn = function (e) {
        if (0 == e.code) {
          ToastView.toastView(e.msg);
          e.msg.split("成功领悟");
          (this.btn_juexing_tisheng.label = "提升"),
            (this.label_lingwu_tips.visible = !0);
          var t = this.subDict.name.split(")"),
            i = this.subDict.name;
          t.length > 1 && (i = t[1]);
          var n = Dictionary.subHeroData[i];
          n && WebSocketService.send({ c: 6418, d: { id: n.id } }),
            WebSocketService.send({ c: 6421, d: { cid: this.subDict.id } });
        } else ToastView.toastView(e.msg);
      }),
      (t.prototype.onLoadJXXiuLianDataFn = function (e) {
        0 == e.code &&
          WebSocketService.send({ c: 6421, d: { cid: this.subDict.id } }),
          ToastView.toastView(e.msg);
      }),
      (t.prototype.onBackPre = function () {
        this.removeSelf();
      }),
      t
    );
  })(ui.JueXingController.JueXingMainControllerUI);
